clear all

use "C:\Users\parks\OneDrive - The Pennsylvania State University\Desktop\Cannabis Legalization and Policy Bundles Projects\IDJP\reg.dta" 

*ivreg LIML
*year fixed
qui: ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59)
est sto m1
qui: ivregress liml suicide phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59)
est sto m2
qui: ivregress liml suicide_p phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59)
est sto m3
qui: ivregress liml suicide_a phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59)
est sto m4
esttab m1 m2 m3 m4, b(3) se(3) scalars(ll_0 ll chi2)

esttab m1 m2 m3 m4, cells(b(fmt(4) star) ci(fmt(4) par)) eform ///
gaps lines collabels(none) label nonumbers ///
mtitles("Depression" "Suicidal Ideation" "Suicidal Plan" "Suicidal Attempts") starlevels(* 0.1 ** 0.05 *** 0.01) ///
addnotes("95% confidence intervals in brackets." /// 
"* p<0.1, ** p<0.05, *** p<0.01")

*Table 2. regression
qui: ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
est sto m1
qui: ivregress liml suicide phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
est sto m2
qui: ivregress liml suicide_p phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)
est sto m3
qui: ivregress liml suicide_a phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)
est sto m4
esttab m1 m2 m3 m4, b(3) se(3) scalars(ll_0 ll chi2)

esttab m1 m2 m3 m4, cells(b(fmt(4) star) ci(fmt(4) par)) eform ///
gaps lines collabels(none) label nonumbers ///
mtitles("Depression" "Suicidal Ideation" "Suicidal Plan" "Suicidal Attempts") starlevels(* 0.1 ** 0.05 *** 0.01) ///
addnotes("95% confidence intervals in brackets." /// 
"* p<0.1, ** p<0.05, *** p<0.01")

ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 

ivregress liml suicide phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 

ivregress liml suicide_p phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)

ivregress liml suicide_a phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)

*post estimation- Figure 1. Predicted Marginal Effects of Policy Bundles on Youth Mental Health
qui: ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
margins, at(phrm=(0(8.3)99.6))
marginsplot, xtitle("Pharmaceutical scale") graphregion(fcolor(white))
graph export 1.png, replace

qui: ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
margins, at(perm=(0(8.3)99.6))
marginsplot, xtitle("Permissive scale") graphregion(fcolor(white))
graph export 2.png, replace

qui: ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
margins, at(fisc=(0(8.3)99.6))
marginsplot, xtitle("Fiscal scale") graphregion(fcolor(white))
graph export 3.png, replace

qui: ivregress liml suicide phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
est sto m2
qui: ivregress liml suicide_p phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)
est sto m3
qui: ivregress liml suicide_a phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)
est sto m4

*Table 3. over identification restrcitions
qui: ivregress liml sad phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
estat firststage
estat overid
qui: ivregress liml suicide phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample) 
estat firststage
estat overid
qui: ivregress liml suicide_p phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)
estat firststage
estat overid
qui: ivregress liml suicide_a phrm perm fisc sxlin bullied drink ciga gender i.age i.year i.race4 (wi = sniff q59) if e(sample)
estat firststage
estat overid

*Table 1. descriptive
su sad suicide suicide_p suicide_a phrm perm fisc wi sxlin bullied drink ciga gender age year sniff q59 if e(sample)
ta age if e(sample)
ta year if e(sample)
ta code if e(sample)
ta race4 if e(sample)
ta sniff if e(sample)
ta q59 if e(sample)

*Appendix A. first-stage
logistic wi phrm perm fisc sniff q59 sxlin bullied drink ciga gender i.age i.year i.race4 if e(sample) 

qui: regress wi phrm perm fisc sniff q59 sxlin bullied drink ciga gender i.age i.year i.race4 if e(sample) 
est sto m0
esttab m0, cells(b(fmt(4) star) ci(fmt(4) par)) eform ///
gaps lines collabels(none) label nonumbers ///
starlevels(* 0.1 ** 0.05 *** 0.01) ///
addnotes("95% confidence intervals in brackets." /// 
"* p<0.1, ** p<0.05, *** p<0.01")
